from django.conf.urls import url
from django.contrib import admin
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token
from . import views
from .views import statistical, users, specs, images, admin_user, skus, permission, groups, spus,brands,channels,options

urlpatterns = [
    # 登录路由
    url(r'^authorizations/$', obtain_jwt_token),
    # ——————————后台首页统计数据展示——————————
    # 用户总量统计
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 日增用户量统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 日活跃用户量统计
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),
    # 日下单用户量统计
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    # 月增用户统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 日分类商品访问量统计
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),

    # ——————————用户管理模块——————————
    url(r'^users/$', users.UserView.as_view()),

    # —————————SPU商品规格表管理模块——————————
    url(r'^goods/simple/$', specs.SpecView.as_view({'get': 'simple'})),

    # —————————SPU商品图片表管理模块——————————
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    # 获取用户组所有可以添加的权限
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),
    # 获取用户的所有分组信息
    url(r'^permission/groups/simple/$', admin_user.AdminUserView.as_view({'get': 'simple'})),
    # 获取所有权限
    url(r'^permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),

    # sku表管理
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),

    # ——————————SPU表获取品牌信息管理————————
    url(r'^goods/brands/simple/$', spus.SPUView.as_view({'get': 'simple'})),
    # ——————————SPU表获取商品分类信息管理————————
    url(r'^goods/channel/categories/$', spus.SPUView.as_view({'get': 'category1'})),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SPUView.as_view({'get': 'categories'})),
    url(r'^goods/images/$', spus.SPUView.as_view({'post': 'images'})),

    # ——————————————频道\品牌表管理——————————————————
    url(r'^goods/channel_types/$', channels.GoodsChannelView.as_view({'get': 'channel_types'})),
    url(r'^goods/categories/$', channels.GoodsChannelView.as_view({'get': 'categories'})),

    # ——————————规格选项表获取品牌信息管理————————
    url(r'^goods/specs/simple/$', options.SpecsOptionsView.as_view({'get': 'simple'})),

]
# ——————————规格选项表表管理模块——————————
router = DefaultRouter()
router.register('specs/options', options.SpecsOptionsView, base_name='spec')
print(router.urls)
urlpatterns += router.urls


# ——————————频道表管理模块——————————
router = DefaultRouter()
router.register('goods/channels', channels.GoodsChannelView, base_name='brand')
print(router.urls)
urlpatterns += router.urls


# ——————————品牌表管理模块——————————
router = DefaultRouter()
router.register('goods/brands', brands.BrandView, base_name='brand')
# print(router.urls)
urlpatterns += router.urls

# ——————————商品规格表管理模块——————————
router = DefaultRouter()
router.register('goods/specs', specs.SpecView, base_name='spec')
urlpatterns += router.urls

# ——————————商品图片表管理模块——————————
router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='image')
# print(router.urls)
urlpatterns += router.urls

# ——————————管理员信息管理模块——————————
router = DefaultRouter()
router.register('permission/admins', admin_user.AdminUserView, base_name='admin')
# print(router.urls)
urlpatterns += router.urls

# ——————————用户权限管理模块——————————
router = DefaultRouter()
router.register('permission/perms', permission.PermissionView, base_name='perm')
# print(router.urls)
urlpatterns += router.urls

# ——————————用户组管理模块——————————
router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='group')
# print(router.urls)
urlpatterns += router.urls

# ——————————SKU表管理模块——————————
router = DefaultRouter()
router.register('skus', skus.SKUView, base_name='sku')
# print(router.urls)
urlpatterns += router.urls

# ——————————SPU表管理模块——————————
router = DefaultRouter()
router.register('goods', spus.SPUView, base_name='spu')
# print(router.urls)
urlpatterns += router.urls





